<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03_父组件与子组件</title>
</head>
<!-- 其实就是组件里套组件了 -->
<body>
    <div id="app">
        <!-- tips: 
            1. 组件名称不能使用驼峰命名法(不管是小驼峰还是大驼峰, vue 都无法识别);
            2. 组件里面不写内容,就算写了也不解析渲染
        -->
        <fathercpn></fathercpn>
        <!-- <soncpn>xxxxx</soncpn> -->
        <!-- <soncpn></soncpn> -->
    </div>
</body>
<script src="../vue.js"></script>
<script>
    //创建一个子组件
    const sonCpn = Vue.extend({
        template: `
            <div>
                <h2>儿子标题...</h2>
                <p>儿子段落内容...</p>
            </div>`
    })

    //创建一个父组件
    const fatherCpn = Vue.extend({
        template: `
            <div>
                <h2>父亲标题...</h2>
                <p>父亲段落内容...</p>
                <sonCpn></sonCpn>
            </div>`,
        components: {
            sonCpn
        }
    })

    const vm = new Vue({
        el: '#app',
        components: {
            fathercpn: fatherCpn,
            //soncpn: sonCpn
        }

    })
</script>

</html>